from utils.utils import unpickle
import cv2

# ann_path='extract_prw_anno_yolo0.0_28270.pkl'
ann_path='extract_prw_anno_yolo0.4_22284.pkl'
dir = '/home/cv7609/zjh/000seqgit_v1/0yolov5_scores/'
extr_anno = dir + ann_path
annotations = unpickle(extr_anno) # anno_dbscan0.3_10.pkl ,annohxw300080.2.pkl
for anno in annotations:
    img_path=anno['img_path']
    img_name=img_path.split('/')[-1]
    boxes=anno['boxes']
    pids=anno['pids']
    src = cv2.imread(img_path)
    for box,pid in zip(boxes,pids):
        pt1 = (int(box[0]), int(box[1]))
        pt2 = (int(box[2]), int(box[3]))
        cv2.rectangle(src,pt1,pt2,color=(255,255,0),thickness=2)
        cv2.putText(src,str(pid),pt1, 1, 2, (255, 0, 0), 2)
    im=src
    f=cv2.resize(im, (int((im.shape[1]) / 2), int((im.shape[0]) / 2)))
    cv2.imshow(img_name,f)
    cv2.waitKey()
